package com.ruoyi.ucar.controller;

import java.util.List;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ucar.domain.TOrderPayDetail;
import com.ruoyi.ucar.service.ITOrderPayDetailService;
import lombok.AllArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * 订单支付详情Controller
 * 
 * @author ruoyi
 * @date 2025-07-25
 */
@RestController
@RequestMapping("/detail")
@AllArgsConstructor
public class TOrderPayDetailController extends BaseController
{
    private final ITOrderPayDetailService tOrderPayDetailService;

    /**
     * 查询订单支付详情列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TOrderPayDetail tOrderPayDetail)
    {
        startPage();
        List<TOrderPayDetail> list = tOrderPayDetailService.selectTOrderPayDetailList(tOrderPayDetail);
        return getDataTable(list);
    }

    /**
     * 导出订单支付详情列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:export')")
    @Log(title = "订单支付详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TOrderPayDetail tOrderPayDetail)
    {
        List<TOrderPayDetail> list = tOrderPayDetailService.selectTOrderPayDetailList(tOrderPayDetail);
        ExcelUtil<TOrderPayDetail> util = new ExcelUtil<>(TOrderPayDetail.class);
        util.exportExcel(response, list, "订单支付详情数据");
    }

    /**
     * 获取订单支付详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tOrderPayDetailService.selectTOrderPayDetailById(id));
    }

    /**
     * 新增订单支付详情
     */
    @PreAuthorize("@ss.hasPermi('system:detail:add')")
    @Log(title = "订单支付详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TOrderPayDetail tOrderPayDetail)
    {
        return toAjax(tOrderPayDetailService.insertTOrderPayDetail(tOrderPayDetail));
    }

    /**
     * 修改订单支付详情
     */
    @PreAuthorize("@ss.hasPermi('system:detail:edit')")
    @Log(title = "订单支付详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TOrderPayDetail tOrderPayDetail)
    {
        return toAjax(tOrderPayDetailService.updateTOrderPayDetail(tOrderPayDetail));
    }

    /**
     * 删除订单支付详情
     */
    @PreAuthorize("@ss.hasPermi('system:detail:remove')")
    @Log(title = "订单支付详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tOrderPayDetailService.deleteTOrderPayDetailByIds(ids));
    }
}
